import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2025-01-20
 * Time:23:37
 */
public class Demo4 {
    private volatile static int isQuit=0;

    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            while (isQuit==0){
                //循环体内什么都没干
                //此时意味着这个循环，一秒钟就会执行很多很多次。
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1退出！");
        });
        t1.start();
        Thread t2=new Thread(()->{
            System.out.println("请输入isQuit:");
            Scanner scanner=new Scanner(System.in);
            //一旦用户输入的值不为0，此时就会使t1线程执行结束
            isQuit=scanner.nextInt();
        });
        t2.start();
    }
}
